home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13876 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.8 KB  |  60 lines

  1. Newsgroups: comp.lang.c
  2. Path: uu4news.netcom.com!zodiac!szh
  3. From: szh@zcon.com (Syed Zaeem Hosain)
  4. Subject: Re: Help:what is wrong this code?
  5. Message-ID: <1996Apr10.160601.21676@zcon.com>
  6. Sender: szh@zcon.com (Syed Zaeem Hosain)
  7. Nntp-Posting-Host: zodiac
  8. Reply-To: szh@zcon.com
  9. Organization: Z Consulting Group
  10. References: <Pine.ULT.3.92.960409210416.383A-100000@henson.cc.wwu.edu>
  11. Date: Wed, 10 Apr 1996 16:06:01 GMT
  12.  
  13. In article <Pine.ULT.3.92.960409210416.383A-100000@henson.cc.wwu.edu>, Norma Mathews <n9341884@henson.cc.wwu.edu> writes:
  14. >> yuehong@brahms.udel.edu (Yue-hong Zheng) writes:
  15. >>
  16. >>
  17. >> >Why it give me 0.0000?
  18. >>
  19. >> >#include <stdio.h>
  20. >> >main () {
  21. >> >double a=9.008;
  22. >> >printf("%f\n",sqrt(a));
  23. >> >return 0;
  24. >> >}
  25. >
  26. >your printf specifer needs to be "%lf", not "%f", since a is a double
  27.  
  28. No, not correct! Please see question 14.2 in the comp.lang.c FAQ.
  29.  
  30. Please look at the FAQ and refer to the answers to questions like the
  31. following (note questiona 12.9 and 15.2, which show that your answer
  32. is not correct:
  33.  
  34. 12.9:   Someone told me it was wrong to use %lf with printf().  How can
  35.         printf() use %f for type double, if scanf() requires %lf?
  36.  
  37. 12.13:  Why doesn't this code:
  38.  
  39.                 double d;
  40.                 scanf("%f", &d);
  41.  
  42.         work?
  43.  
  44. 14.2:   I'm trying to take some square roots, but I'm getting crazy
  45.         numbers.
  46.  
  47. 15.2:   How can %f be used for both float and double arguments in
  48.         printf()?  Aren't they different types?
  49.  
  50. The FAQ can be found at rtfm.mit.edu:/pub/usenet/comp.lang.c/
  51.  
  52.                                 Z
  53.  
  54.  
  55. -- 
  56. -------------------------------------------------------------------------
  57. | Syed Zaeem Hosain          P. O. Box 610097            (408) 441-7021 |
  58. | Z Consulting Group        San Jose, CA 95161             szh@zcon.com |
  59. -------------------------------------------------------------------------
  60.